﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Configurations;
using System.Xml.Serialization;

//不支持序列化的接口
namespace Pixysoft.Framework.Reports
{
    //xml ignore
    public interface IReportTable
    {
        string ReportName { get; }

        IReportColumnCollection Columns { get;}

        IReportRowCollection Rows { get;}
    }

    //xml ignore
    public interface IReportColumn
    {
        void Initialize();

        int ColumnIndex { get;}

        string Identifier { get;}

        string HeaderName { get;}

        /// <summary>
        /// 当前column依赖的columnname集合 用于判断cell的位置
        /// </summary>
        string[] ColumnNames { get;}

        IReportColumnSetting Setting { get;}

        IReportColumn Parent { get;set;}

        IReportColumnCollection Children { get;}
    }

    //xml ignore
    public interface IReportColumnCollection : IEnumerable<IReportColumn>, IEnumerator<IReportColumn>
    {
        int Count { get;}

        IReportColumn this[string headerName] { get;}

        IReportColumn this[int columnIndex] { get;}

        IReportColumn[] ToArray();

        bool Contains(IReportColumn value);

        IReportColumn NewColumn(string headerName, int columnIndex, IReportColumnSetting setting);

        void Add(IReportColumn column);

        IReportColumn RemoveAt(int columnIndex);

        void Remove(IReportColumn column);

        void RemoveAll();
    }

    //xml ignore
    public interface IReportRow
    {
        /// <summary>
        /// 行编号
        /// </summary>
        int RowIndex { get;}

        /// <summary>
        /// 唯一id
        /// </summary>
        string Identifier { get;}

        /// <summary>
        /// 表头名字
        /// </summary>
        string HeaderName { get;}

        /// <summary>
        /// 行配置
        /// </summary>
        IReportRowSetting Setting { get;}

        /// <summary>
        /// 父行
        /// </summary>
        IReportRow Parent { get;set;}


        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="setting"></param>
        void Initialize(IReportSetting setting);

        /// <summary>
        /// 所引用的数据列名
        /// </summary>
        string[] ColumnNames { get;}


        object this[int columnIndex] { get;set;}

        IReportRowCollection Children { get;}

        IReportCellCollection Cells { get;}
    }

    //xml ignore
    public interface IReportRowCollection : IEnumerable<IReportRow>, IEnumerator<IReportRow>
    {
        int Count { get;}

        IReportRow this[string headerName] { get;}

        IReportRow this[int rowIndex] { get;}

        IReportRow[] ToArray();

        bool Contains(IReportRow value);

        IReportRow GetRow(string rowIdentifier);

        IReportRow NewRow(string headerName, string rowIdentifier, IReportRowSetting setting);

        void Add(IReportRow row);

        IReportRow RemoveAt(int rowIndex);

        void Remove(IReportRow row);

        void RemoveAll();
    }

    //xml ignore
    public interface IReportCell
    {
        int ColumnIndex { get;}

        int RowIndex { get;}

        IReportColumn Column { get;set;}

        IReportCellSetting Setting { get;}

        IReportRow Row { get;set;}

        object Value { get; set;}

        bool NeedCellValue(string columnName, object value);

        void AddCellValue(string columnName, object value);

        void Caculate();
    }

    //xml ignore
    public interface IReportCellCollection : IEnumerable<IReportCell>, IEnumerator<IReportCell>
    {
        int Count { get;}

        IReportCell GetCell(int columnIndex);

        object this[int columnIndex] { get;}
    }
}
